package com.ruoyi.web.controller.biz.hugong.openapi;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.OssUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * The type Upload open api.
 *
 * @ClassName UploadOpenApi
 * @Description
 * @Author sizegang
 * @Date2024/12/12 22 :56
 */
@RestController
@RequestMapping("/openapi/upload")
public class UploadOpenApi extends BaseController {

    @Autowired
    private OssUtil ossUtil;

    /**
     * Upload file ajax result.
     *
     * @param file the file
     * @return the ajax result
     */
    @ApiOperation("通用上传文件")
    @PostMapping("/common")
    public AjaxResult uploadFile(MultipartFile file) throws IOException {
        String uploadFileUrl = ossUtil.uploadFile(file);
        return AjaxResult.success("操作成功", uploadFileUrl);
    }

}
